<template>
    <div id="main" style="margin: 10px auto;width: 500px;height: 500px"></div>
</template>

<script>
    import request from "../utils/request";

    const echarts = require('echarts');

    export default {
        name: "PassRate",
        data () {
            return {
                data1:['[0%,10%)','[10%,20%)','[20%,30%)','[30%,40%)','[40%,50%)','[50%,60%)','[60%,70%)','[70%,80%)','[80%,90%)','[90%,100%)'],
                data2:[]
            }
        },
        mounted(){
            this.initChart();
        },
        methods: {
            initChart(){
                var chartDom = document.getElementById('main');
                var myChart = echarts.init(chartDom);
                var option;
                request.get("/jobCodeHigh",{ // 请求/wordCloud接口
                    params: {
                        pageNum: this.currentPage,
                        pageSize: this.pageSize,
                        search: this.search
                    }
                }).then(res=>{
                    this.data2=[];
                    for(let i=0;i<res.data.records.length;i++){
                        this.data2.push(res.data.records[i]['num']);

                    }


                    option = {
                        title: { text: '笔试题通过率分布图' },
                        toolbox: {  // 显示保存图片的按钮
                            show: true,
                            orient: 'horizontal',
                            bottom: 10,
                            right: 20,
                            feature: {
                                saveAsImage: {}
                            }
                        },
                        xAxis: {
                            type: 'category',
                            // boundaryGap: false,
                            data: this.data1 ,
                            name:'通过率区间',
                            axisLabel : {
                                interval:0,
                                rotate:"55"
                            }

                        },
                        yAxis: {
                            type: 'value',
                            name:'题目数量',

                        },
                        series: [{
                            // data: [0,2,27,72,36,15,6,2,0,0],
                            data:this.data2,
                            type: 'line',
                            smooth: true
                        }]
                    };
                    console.log(this.data2);
                    // console.log(JSON.parse(JSON.stringify(this.data2)));
                    option && myChart.setOption(option);}
                )
            },
        }
    }
</script>

<style scoped>

</style>